package ui.swing.table;

import java.awt.Color;

import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.TableModel;

import ui.swing.STableRenderer;
import ui.swing.model.Stoppable;

public abstract class AbstractTableUI extends JScrollPane{
	
	private static final long serialVersionUID = -1796287310095594264L;
	private JTable table = new JTable();
	protected int c;
	
	public AbstractTableUI() {
		table.setShowGrid(false);
		table.setModel(getModel());
		table.setDefaultRenderer(Object.class, new STableRenderer());
		setViewportView(table);
		setBackground(Color.WHITE);
	}
	
	public AbstractTableUI(int c) {
		this.c = c;
		table.setShowGrid(false);
		table.setModel(getModel());
		table.setDefaultRenderer(Object.class, new STableRenderer());
		setViewportView(table);
		setBackground(Color.WHITE);
	}

	public abstract TableModel getModel();
	
	public JTable getTable(){
		return table;
	}
	
	public void killModelThread(){
		Stoppable s = (Stoppable)getModel();
		s.stop();
	}
}
